package com.hhxy.Enum;

public enum HttpCode {

    HTTP_200("200","success","请求成功"),
    HTTP_201("201","success","新建或修改数据成功"),
    HTTP_204("204","success","删除成功，不需要返回结果"),
    HTTP_400("400","ERROR","请求参数错误，请检查参数"),
    HTTP_401("401","ERROR","用户没有权限，请先登录验证权限"),
    HTTP_404("404","ERROR","资源不存在"),
    HTTP_500("500","ERROR","服务器无响应，或者出错");

    private String code;
    private String status;
    private String description;

    HttpCode(String code, String status,String description) {
        this.code = code;
        this.status = status;
        this.description = description;
    }

    public String getCode() {
        return code;
    }

    public String getStatus() {
        return status;
    }

    public String getDescription() {
        return description;
    }


    public static HttpCode getByCode(String code) {
        for (HttpCode _enum : values()) {
            if (_enum.getCode() == code) {
                return _enum;
            }
        }
        return null;
    }

    @Override
    public String toString() {
        return description.toString();
    }
}
